package com.reebake.ideal.infra.controller.client;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.reebake.ideal.infra.client.ContentClobClient;
import com.reebake.ideal.infra.entity.ContentClob;
import com.reebake.ideal.infra.entity.ContentClobDTO;
import com.reebake.ideal.infra.service.ContentClobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/client/content/clob")
public class ContentClobClientController implements ContentClobClient {
    @Autowired
    private ContentClobService contentClobService;

    @Override
    public String saveOrUpdate(ContentClobDTO contentClobDTO) {
        ContentClob contentClob = BeanUtil.copyProperties(contentClobDTO, ContentClob.class);
        contentClobService.saveOrUpdate(contentClob);
        return contentClob.getContentClobId();
    }

    @Override
    public ContentClobDTO queryById(String contentClobId) {
        return BeanUtil.copyProperties(contentClobService.getById(contentClobId), ContentClobDTO.class);
    }

    @Override
    public void removeByIds(String... ids) {
        contentClobService.removeByIds(CollectionUtil.newArrayList(ids));
    }

}
